﻿import { ControlTypeEnum, validateTriggerEnum,  validateTypeEnum, } from "@/components/coreshop-form/enum";
import { IFormSchema } from "@/components/coreshop-form/type";

const formSchema: IFormSchema = {
  saveDataSourceKey: "{{ModelClassName}}/DoCreate",
  editDataSourceKey: "{{ModelClassName}}/DoEdit",
  queryDataSourceKey: "{{ModelClassName}}/GetEdit",
  filter: null,
  labelCol: { span: 3 },
  fieldValueModel: "model",
  fields: [
  {% for field in ModelFields %}
  
    {% if  field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail'  or field.DbColumnName contains 'Thumbnail' %}
         {
            key: "{{field.DbColumnName}}",
            name: "{{field.ColumnDescription}}",
            value: "",
            placeholder: "请上传{{field.ColumnDescription}}",
            type: ControlTypeEnum.FILE,
        },
    
     {% elsif field.DataType == 'nvarchar' %}
            {
                  key: "{{field.DbColumnName}}",
                  name: "{{field.ColumnDescription}}",
                  value: "",
                  placeholder: "请输入{{field.ColumnDescription}}",
                  type: ControlTypeEnum.STRING,
                  config: {
                    rules: [
                      {
                        required: true,
                        message: "{{field.ColumnDescription}}不能为空",
                        trigger: validateTriggerEnum.blur,
                        type: validateTypeEnum.string,
                      },
                    ],
                  },
            },
     
     {% elsif  field.DataType == 'int' or field.DataType == 'bigint' %}
            {
              key: "{{field.DbColumnName}}",
              name: "{{field.ColumnDescription}}",
              placeholder: "请输入{{field.ColumnDescription}}",
              type: ControlTypeEnum.NUMBER,
              value: 1000,
              config: {
                rules: [
                  {
                    required: true,
                    message: "{{field.ColumnDescription}}不能为空",
                    trigger: validateTriggerEnum.blur,
                    type: validateTypeEnum.number,
                  },
                ],
              },
    },

    {% elsif  field.DataType == 'datetime' %}
          {
            key: "{{field.DbColumnName}}",
            name: "请选择{{field.ColumnDescription}}",
            placeholder: "请选择{{field.ColumnDescription}}",
            type: ControlTypeEnum.DATE_PICKER,
          },

    {% elsif  field.DataType == 'bit' %}
        {
            key: "{{field.DbColumnName}}",
            name: "{{field.ColumnDescription}}",
            value: false,
            placeholder: "{{field.ColumnDescription}}",
            type: ControlTypeEnum.SWITCH,
            config: {
                rules: [
                    {
                        required: true,
                        message: "{{field.ColumnDescription}}",
                        trigger: validateTriggerEnum.blur,
                        type: validateTypeEnum.boolean
                    },
                ],
                checkedLabel: "是",
                unCheckedLabel: "否",
            },
        },

     {% else %}
            {
                  key: "{{field.DbColumnName}}",
                  name: "{{field.ColumnDescription}}",
                  value: "",
                  placeholder: "请输入{{field.ColumnDescription}}",
                  type: ControlTypeEnum.STRING,
                  config: {
                    rules: [
                      {
                        required: true,
                        message: "{{field.ColumnDescription}}不能为空",
                        trigger: validateTriggerEnum.blur,
                        type: validateTypeEnum.string,
                      },
                    ],
                  },
            },
     {% endif %}
  {% endfor %}
  ]}

export default formSchema;
